package net.siufung.security.base.exception;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Getter;
import net.siufung.core.result.IResultType;
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;

/**
 * @author 陈建峰
 * @since 2022/5/3 10:54 下午
 */
@SuppressWarnings("deprecation")
@JsonSerialize(using = Oauth2ExceptionSerializer.class)
public class Oauth2Exception extends OAuth2Exception {

    private static final long serialVersionUID = -4594756173796157146L;
    @Getter
    private Integer errorCode;

    public Oauth2Exception(String msg, Integer errorCode) {
        super(msg);
        this.errorCode = errorCode;
    }

    public Oauth2Exception(String msg) {
        super(msg);
    }

    public Oauth2Exception(IResultType resultType) {
        super(resultType.getMessage());
        this.errorCode = resultType.getCode();
    }

}
